package com.huiquan.vocab.utils;

import java.util.HashMap;
import java.util.Map;

import com.huiquan.vocab.domain.SymptomCheckResult;

public class SymptomCheckResultUtil {

	public static SymptomCheckResult right() {

		SymptomCheckResult right = new SymptomCheckResult();
		right.setFlag(true);

		return right;
	}

	public static SymptomCheckResult wrong(String type, String msg) {

		SymptomCheckResult wrong = new SymptomCheckResult();
		wrong.setFlag(false);

		Map<String, Object> errorMsg = new HashMap<>();
		errorMsg.put(type, msg);
		wrong.setErrorMsg(errorMsg);

		return wrong;
	}

	public static void printResult(SymptomCheckResult scr) {

		System.out.println(scr.getFlag());

		Map<String, Object> errorMsg = scr.getErrorMsg();

		if (errorMsg != null && !errorMsg.isEmpty()) {
			StringBuffer msg = new StringBuffer();
			for (String key : errorMsg.keySet()) {
				msg.append(key);
				msg.append(": ");
				msg.append(errorMsg.get(key));
				msg.append("\n");
			}

			System.out.println(msg.toString());
		}
	}

}
